You are here: Symbol Reference > Dew Namespace > Dew.Stats Namespace > Dew.Stats.Units Namespace > Classes > Statistics Class > Statistics Methods > Covariance Method > Statistics.Covariance Method ([In] TDenseMtxVec, [In] TDenseMtxVec, [In] TMtx, bool)
Dew Stats for .NET
ContentsIndexHome
PreviousUpNext
Statistics.Covariance Method ([In] TDenseMtxVec, [In] TDenseMtxVec, [In] TMtx, bool)

Calculate the variance-covariance matrix (Result), assuming vectors X and Y are two variable and their elements are the observations.

Syntax
C#
Visual Basic
public static void Covariance([In] TDenseMtxVec X, [In] TDenseMtxVec Y, [In] TMtx aResult, bool NormN);

X and Y can be two vectors or matrices of equal size. In first case two vectors are treated as two variables, X values as first variable observables, Y vector values as second variable observabled. In second case two matrices are treated as two variables X and Y, all X values as X variable observables and all Y values as Y variable observables.

For column-vector valued random variables X and Y with respective expected values mu and nu, and respective scalar components m and n, the covariance is defined to be the m×n matrix called the covariance matrix: 

 

 

Calculate the covariance matrix from two vectors representing two variables.

using Dew.Math; using Dew.Stats.Units; namespace Dew.Examples { private void Example() { Vector data1 = new Vector(0); Vector data2 = new Vector(0); Matrix cov = new Matrix(0,0); data1.SetIt(false,new double[] {1.2,3}); data2.SetIt(false,new double[] {5,5.5}); Statistics.Covariance(data1,data2,cov,false); // cov = [1.62, 0.45, // 0.45, 0.125] } }
Copyright (c) 1999-2024 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!